import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'discover.dart';
import 'bookshelf.dart';
import 'profile.dart';
import 'home.dart';

import '../../controllers/tabs_controller.dart';
import '../../utils/resability.dart';

class TabsPage extends StatelessWidget {
  final BottomNavController navController = Get.find<BottomNavController>();

  final List<Widget> pages = [
    HomePage(),
    DiscoverPage(),
    BookshelfPage(),
    ProfilePage(),
  ];

  TabsPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomNavigationBar: Obx(
        () => BottomNavigationBar(
          currentIndex: navController.selectedIndex.value,
          onTap: navController.changePage, // 点击切换页面
          type: BottomNavigationBarType.fixed,
          backgroundColor: bar_color,
          // 设置阴影
          elevation: 10.0,
          selectedItemColor: button_color,
          unselectedItemColor: text_color,
          showSelectedLabels: false,
          showUnselectedLabels: false,
          items: [
            BottomNavigationBarItem(
              icon: Icon(Icons.home_outlined),
              label: '首页',
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.looks_outlined),
              label: '发现',
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.book_outlined),
              label: '书架',
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.person_outlined),
              label: '我的',
            ),
          ],
        ),
      ),
      // --------------------------------------------------------
      body: Obx(() => pages[navController.selectedIndex.value]),
    );
  }
}
